package com.linkoog.devtools.type.impl;

import com.linkoog.devtools.type.LiteralType;
import lombok.Getter;

/**
 *  常量类型
 */
public enum LiteralTypes implements LiteralType {

    BooleanPrimitiveType("boolean", "boolean"),
    CharPrimitiveType("char", "char"),
    DoublePrimitiveType("double", "double"),
    FloatPrimitiveType("float", "float"),
    BytePrimitiveType ("byte", "byte"),
    IntegerPrimitiveType("int", "int"),
    LongPrimitiveType("long", "long"),
    ShortPrimitiveType("short", "short"),

    BooleanPrimitiveBoxType("Boolean", "java.lang.Boolean"),
    BytePrimitiveBoxType("Byte", "java.lang.Byte"),
    CharPrimitiveBoxType("Character", "java.lang.Character"),
    DoublePrimitiveBoxType("Double", "java.lang.Double"),
    FloatPrimitiveBoxType("Float", "java.lang.Float"),
    IntegerPrimitiveBoxType("Integer", "java.lang.Integer"),
    LongPrimitiveBoxType("Long", "java.lang.Long"),
    ShortPrimitiveBoxType("Short", "java.lang.Short"),

    NumberLiteralType("Number", "java.lang.Number"),
    BigDecimalLiteraltype("BigDecimal", "java.math.BigDecimal"),
    BigIntegerLiteralType("BigInteger", "java.math.BigInteger"),
    StringLiteralType("String", "java.lang.String"),
    VoidLiteralType("void", "java.lang.Void"),
    ClassLiteralType("Class", "java.lang.Class"),
    EnumLiteralType("Enum", "java.lang.Enum"),
    SerializableLiteralType("Serializable", "java.lang.Serializable"),



    //date日期类型
    DateLiteralType("Date", "java.util.Date"),
    LocalDateLiteralType("LocalDate", "java.time.LocalDate"),
    LocalDateTimeLiteralType("LocalDateTime", "java.time.LocalDateTime"),
    LocalTimeLiteralType("LocalTime", "java.time.LocalTime")


    ;






    /**
     *  type的名称
     */
    @Getter
    protected final String typeName;
    /**
     *  type的全类名
     */
    @Getter
    protected final String typeFullName;

    LiteralTypes(String typeName, String typeFullName) {
        this.typeName = typeName;
        this.typeFullName = typeFullName;
    }

    public static LiteralType valueByName(String typeName){
        if (typeName == null || typeName.length() == 0){
            return null;
        }
        for (LiteralTypes value : values()) {
            if (value.typeName.equals(typeName)) return value;
        }
        return null;
    }

    public static LiteralType valueByFullName(String qualifiedName){
        if (qualifiedName == null || qualifiedName.isEmpty()){
            return null;
        }
        for (LiteralTypes value : values()) {
            if (value.typeFullName.equals(qualifiedName)) return value;
        }
        return null;
    }


}
